<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="centre/manage/include :: header"></head>

<body class="gray-bg">
	<div class="wrapper wrapper-content ">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="rechargeForm">
							<input type="hidden" th:value="${supply.id}" id="id" name="id">
							<table class="table table-bordered table-condensed">
								<tbody>
								<tr>
									<th class="required" style="text-align: right;">供应商名称</th>
									<td th:text="${supply.name}"></td>
								</tr>
								<tr>
									<th class="required" style="text-align: right;">当前余额</th>
									<td><span class="label label-danger" th:text="${supply.balance}"></span></td>
								</tr>
								<tr>
									<th class="required" style="text-align: right;">选项</th>
									<td>
									   <label class="radio-inline"><input type="radio" id="type" name="type" value="0" checked="checked"/>增加</label> 
							           <label class="radio-inline"><input type="radio"  id="type" name="type" value="1" />减少</label>
									</td>
								</tr>
								<tr>
									<th class="required" style="text-align: right;">金额</th>
									<td><input name="money"  id="money"  class="form-control" type="text" value=""/></td>
								</tr>
								<tr>
									<th class="required" style="text-align: right;">备注</th>
									<td><input id="remark" name="remark" class="form-control" type="text" value=""/></td>
								</tr>
								</tbody>
							</table>
							<div class="form-group text-center">
								<div class="col-sm-8 col-sm-offset-2">
									<button class="btn btn-primary" id="saveBtn"  onclick="save()"><i class="fa fa-check"></i>保存</button>
									<div class="btn btn-danger" onclick="closeDow()"><i class="fa fa-remove"></i> 关闭</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

	</div>
	<div th:include="centre/manage/include::footer"></div>
	<script type="text/javascript">
		function closeDow() {
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		}

 function save() {
	 var type =  $("input[name='type']:checked").val();
	  var money =  $("#money").val();
	 if(type == '' || type == null){
		 parent. layer.msg("请选择加减！！！");
	        return;
	    }
	 if(money == '' || money == null){
		 parent. layer.msg("请输入金额！！！");
	        return;
	    }
	 $("#saveBtn").attr({"disabled":"disabled"});
	 $("#saveBtn").hide();
            $.ajax({
                cache : true,
                type : "POST",
                url : "/mall/supply/suppBalanceRecharge",
                data : $('#rechargeForm').serialize(),// 你的formid
                async : false,
                error : function(request) {
                    parent.layer.alert("Connection error");
                },
                success : function(data) {
                    if (data.code == 0) {
                        parent.layer.msg("操作成功");
                        parent.reLoad();
                        var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                        parent.layer.close(index);

                    } else {
                        if (data.msg) {
                            parent.layer.alert(data.msg)
                        }else {
                            window.location.href = "/";
                        }
                    }

                }
            });

        } 
	</script>
</body>
</html>
